package server

import (
	"context"
	"fmt"
	"gitee.com/kelvins-io/kelvins-template/proto/kelvins_template_proto/kelvins_template"
	"gitee.com/kelvins-io/kelvins-template/service"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

type YourServer struct{}

func NewYourServer() kelvins_template.YourServiceServer {
	return new(YourServer)
}

func (s *YourServer) Service1(ctx context.Context, req *kelvins_template.Service1Request) (*kelvins_template.Service1Response, error) {
	return &kelvins_template.Service1Response{
		Common: &kelvins_template.CommonResponse{
			Code: kelvins_template.RetCode_SUCCESS,
			Msg:  fmt.Sprintf("%d", req.Id),
		},
		Result: service.Service1(ctx),
	}, status.Error(codes.NotFound, "not found")
}

func (s *YourServer) Service2(ctx context.Context, req *kelvins_template.Service2Request) (*kelvins_template.Service2Response, error) {
	return &kelvins_template.Service2Response{
		Common: &kelvins_template.CommonResponse{
			Code: kelvins_template.RetCode_SUCCESS,
			Msg:  fmt.Sprintf("%d", req.Id),
		},
		Result: service.Service2(ctx),
	}, nil
}

func (s *YourServer) Service3(ctx context.Context, req *kelvins_template.Service3Request) (*kelvins_template.Service3Response, error) {
	return &kelvins_template.Service3Response{
		Common: &kelvins_template.CommonResponse{
			Code: kelvins_template.RetCode_SUCCESS,
			Msg:  fmt.Sprintf("%d", req.Id),
		},
		Result: service.Service3(ctx),
	}, nil
}
